#include "SFMLText.h"
#include "..\ScaleFactor.h"

using namespace vn;

SFMLText::SFMLText(float p_layer) : SFMLDrawable(p_layer)
{
	m_text.setScale(SCALEF, SCALEF);
}

SFMLText::~SFMLText(void){}

void SFMLText::setFont(const sf::Font& p_font)
{
	m_text.setFont(p_font);
}

void SFMLText::draw(sf::RenderWindow& p_renderWindow)
{
	p_renderWindow.draw(m_text);
}

void SFMLText::draw(sf::RenderTexture& p_renderTexture)
{
	p_renderTexture.draw(m_text);
}

void SFMLText::setAngle(float p_angle)
{
	m_text.setRotation(p_angle);
}

void SFMLText::setScale(const vn::Scale& p_scale)
{
	m_text.setScale(p_scale.x * SCALEF, p_scale.y * SCALEF);
}

void SFMLText::setScale(float x, float y)
{
	m_text.setScale(x * SCALEF, y * SCALEF);
}

void SFMLText::setPosition(const vn::Vector2& p_position)
{
	m_text.setPosition(p_position.x * SCALEF, p_position.y * SCALEF);
}

void SFMLText::setPosition(float x, float y)
{
	m_text.setPosition(x * SCALEF, y * SCALEF);
}

void SFMLText::setOrigin(const vn::Vector2& p_origin)
{
	m_text.setOrigin(p_origin.x, p_origin.y);
}

void SFMLText::setOrigin(float x, float y)
{
	m_text.setOrigin(x, y);
}

void SFMLText::setColor(const vn::Color& p_color)
{
	m_text.setColor(sf::Color(p_color.r, p_color.g, p_color.b, p_color.a));
}

void SFMLText::setString(const std::string& p_string)
{
	m_text.setString(p_string);
}

const vn::Vector2 SFMLText::getPosition() const
{
	return vn::Vector2(m_text.getPosition().x / SCALEF, m_text.getPosition().y / SCALEF);
}

const vn::Scale SFMLText::getScale() const
{
	return vn::Scale(m_text.getScale().x / SCALEF, m_text.getScale().y);
}

const float SFMLText::getAngle() const
{
	return m_text.getRotation();
}

const vn::Vector2 SFMLText::getOrigin() const
{
	return vn::Vector2(m_text.getOrigin().x, m_text.getOrigin().y);
}

const vn::Color SFMLText::getColor() const
{
	return vn::Color(m_text.getColor().r, m_text.getColor().g, m_text.getColor().b, m_text.getColor().a);
}

const vn::FloatRect SFMLText::getLocalBounds() const
{
	sf::FloatRect rect = m_text.getLocalBounds();
	return vn::FloatRect(rect.left, rect.top, rect.width, rect.height);
}

void SFMLText::setDoRender(bool p_value)
{
	m_render = p_value;
}